import java.util.Arrays;
import java.util.Scanner;

public class Sort {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] array = new int[5];
        for (int i = 0; i <5 ; i++) {
            array[i] = scanner.nextInt();
        }
        mergeSort(array);
        System.out.println(Arrays.toString(array));
    }
    // 归并排序---递归
    public static void mergeSort(int[] array){
        // write code  here
        mergeSortFun(array,0,array.length-1);
    }

    private static void mergeSortFun(int[] array, int start, int end) {
        if(start>=end){
            return;
        }
        int mid = (start+end)/2;
        mergeSortFun(array,start,mid);
        mergeSortFun(array,mid+1,end);
        merge(array,start,mid,end);
    }

    private static void merge(int[] array, int start, int mid, int end) {
       int[] newArr  = new int[end-start+1];
       int left = start;
       int s2 = mid+1;
        int k = 0;
        while(start<=mid&&s2<=end){
           if(array[start]<=array[s2]){
               newArr[k++] = array[start++];
           }else {
                newArr[k++] = array[s2++];
           }
       }
       while(start<=mid){
           newArr[k++] = array[start++];
       }
       while(s2<=end){
           newArr[k++] = array[s2++];
       }
       for(int i=0;i<newArr.length;i++){
           array[i+left] = newArr[i];
       }
    }

    // 归并排序---非递归
    public static void mergeSort2(int[] array){
        // write code  here
        int gap = 1;
        while(gap<array.length){
            for(int i=0;i<array.length;i+=gap*2){
                int left = i;
                int mid = i+gap-1;
                int right = i+gap;
                if(mid>=array.length){
                    mid = array.length-1;
                }
                if(right>=array.length){
                    right = array.length-1;
                }
                merge(array,left,mid,right);
            }
            gap*=2;
        }
    }

// 计数排序
    public static void countSort(int[] array){
        // write code  here
        int minVal = array[0];
        int maxVal = array[0];
        for (int i = 0; i < array.length; i++) {
            if(array[i]<minVal){
                minVal = array[i];
            }
            if(array[i]>maxVal){
                maxVal = array[i];
            }
        }
        int[] newArr = new int[maxVal-minVal+1];
        for (int i = 0; i < array.length; i++) {
            newArr[array[i]-minVal] ++;
        }
        int index = 0;
        for (int i = 0; i < array.length; i++) {
            while(newArr[i]>0){
                array[index++] = i+minVal;
                newArr[i]--;
            }
        }
    }
}
